from random import randint

new_list = []
new_dict = {}

for i in range(20):
    new_list.append(randint(1, 20))

for i in new_list:
    new_dict.update({i: new_list.count(i)})

print(sorted(new_dict.items(), key=lambda x: x[1], reverse=True)[0:3])


# 完成的不错
